﻿namespace Appology.SugarSync.Explorer.Phone
{
    public class ApplicationState
    {
        private static SugarSyncApiSettings _current;

        public static SugarSyncApiSettings Current
        {
            get
            {
                if (_current == null)
                {
                    _current = SugarSyncApiSettings.Load();

                    if (string.IsNullOrEmpty(_current.AccessKey) || string.IsNullOrEmpty(_current.PrivateAccessKey))
                    {
                        _current.AccessKey = "<put your access key here>";
                        _current.PrivateAccessKey = "<put your private access key here>";

                        _current.Account.SetApiCredentials(_current.AccessKey, _current.PrivateAccessKey);
                    }
                }

                return _current;
            }
        }

        public void Save()
        {
            _current.Save();
        }
    }
}